package com.atguigu.spzx.manager.task;

import com.atguigu.spzx.manager.service.order.OrderStatisticsService;
import com.atguigu.spzx.model.entity.order.OrderStatistics;
import jakarta.annotation.Resource;
import org.joda.time.DateTime;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class SpzxOrderTask {
    @Resource
    OrderStatisticsService orderStatisticsService;
    //cron表达式一共7位：
    //但是springTask支持6位

    //每过5秒执行一次定时任务： 0/5 * * * * *
    //每分钟的 3/10/21/33/50 各执行一次定时任务：  3,10,21,33,50 * * * * *
//    @Scheduled(cron = "0/5 * * * * *")
//    public void task1(){
//        System.out.println(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
//    }
    //定时任务：凌晨3点统计昨天的订单的数据 保存到表中
    @Scheduled(cron = "0 0 3 * * *")
//    @Scheduled(cron = "50 06 15 * * *")// 15
    public void generateOrderStatisticsTask(){

        orderStatisticsService.generateOrderStatistics();
    }
}
